use rand::Rng;

pub fn gen_app_secret_and_nonce(_appkey: String) -> (String, String) {
    let secret_bytes = rand::thread_rng().gen::<[u8; 16]>();
    let nonce_bytes = rand::thread_rng().gen::<[u8; 12]>();
    (hex::encode(secret_bytes), hex::encode(nonce_bytes))
}

#[cfg(test)]
mod test {
    use crate::utils::random_byte;
    #[test]
    fn test_gen_app_secret_and_nonce() {
        // 32 length
        let (secret, nonce) = random_byte::gen_app_secret_and_nonce("appkey".to_owned());
        println!(
            "secret = {:?},nonce = {:?},secret length = {:?}, nonce length = {:?}",
            secret,
            nonce,
            hex::decode(&secret).unwrap().len(),
            hex::decode(&nonce).unwrap().len()
        );
    }
}
